class P11547_39643 {

    public static void main(String[] args) {
//        "Multiply n by 567, then divide the result by 9, then add 7492, then multiply by 235, then divide by 47, then subtract 498. What is the digit in the tens column?"
       
        int cases  = Integer.parseInt(readLn());
       
        for (int k = 0; k < cases; k++) {
            int n = Integer.parseInt(readLn());
           
            int result = (((((n * 567) / 9) + 7492) * 235) / 47) - 498;
           
            int answer = (result / 10) % 10;
           
            System.out.println(Math.abs(answer));
           
           
        }
       
    }
   
    static String readLn() {
        String newLine = System.getProperty("line.separator");
        StringBuilder buffer = new StringBuilder();
        int car = -1;
        try {
            car = System.in.read();
            while ((car > 0) && (car != newLine.charAt(0))) {
                buffer.append((char) car);
                car = System.in.read();
            }
            if (car == newLine.charAt(0))
                System.in.skip(newLine.length() - 1);
        } catch (java.io.IOException e) {
            return (null);
        }
        if ((car < 0) && (buffer.length() == 0))
            return (null);
        return (buffer.toString()).trim();
    }

}